/**
 * Copyright(c) 2013-2016 by Puhuifinance Inc.
 * All Rights Reserved
 */
package com.puhui.chome.manager;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.puhui.chome.dao.MonitorItemDao;
import com.puhui.chome.model.MonitorItem;

/**
 * @author dingxingang
 */
@Component
public class MonitorItemManager {

    @Autowired
    private MonitorItemDao monitorItemDao;

    /**
     * 添加
     * 
     * @author dingxingang
     * @param monitorItem
     */
    public void addMonitorItem(MonitorItem monitorItem) {
        monitorItem.setCreateTime(new Date());
        monitorItem.setUpdateTime(new Date());
        monitorItem.setEnable(true); // 启用
        monitorItem.setAlarm(false); // 正常
        monitorItemDao.addMonitorItem(monitorItem);
    }

    /**
     * 根据ID获取信息
     * 
     * @author dingxingang
     * @param id
     * @return
     */
    public MonitorItem getMonitorItemById(Long id) {
        return monitorItemDao.getMonitorItemById(id);
    }

    /**
     * 获取总记录数
     * 
     * @author dingxingang
     * @param param
     * @return
     */
    public long findMonitorItemCount(Map<String, Object> param) {
        return monitorItemDao.findMonitorItemCount(param);
    }

    /**
     * 查询列表
     * 
     * @author dingxingang
     * @param param
     * @return
     */
    public List<MonitorItem> findMonitorItem(Map<String, Object> param) {
        return monitorItemDao.findMonitorItem(param);
    }

    /**
     * 修改监控
     * 
     * @author dingxingang
     * @param monitorItem
     * @return
     */
    public int updateMonitorItem(MonitorItem monitorItem) {
        return monitorItemDao.updateMonitorItem(monitorItem);
    }

    /**
     * 获取待监控项
     * 
     * @author dingxingang
     * @param minute
     *            执行时间分
     * @return
     */
    public List<MonitorItem> findMonitorItemByExecuteMinute(int minute) {
        return monitorItemDao.findMonitorItemByExecuteMinute(minute);
    }

}
